-
Notifications
You must be signed in to change notification settings - Fork 763
Add cleanup of old account events #6576
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add cleanup of old account events #6576
Conversation
This commit implements a data cleanup feature for account events: - Adds migration to perform initial cleanup of account events older than 2 years - Adds management command 'cleanup_old_account_events' for periodic cleanup - Can be scheduled via crontab to run daily The cleanup can be run manually with: python manage.py cleanup_old_account_events
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's also add the cron entry to run once per week. r+wc
|
||
|
||
def delete_old_account_events(apps, schema_editor): | ||
AccountEvent = apps.get_model('users', 'AccountEvent') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In order to keep this code DRY and have a single place where we delete accounts, you can use the call_command
function to call the management command that you wrote
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
from datetime import timedelta | ||
|
||
|
||
def delete_old_account_events(apps, schema_editor): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's match the name with the one of the management command
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
This commit implements a data cleanup feature for account events:
The cleanup can be run manually with:
python manage.py cleanup_old_account_events
This
.delete()[0]
is an interesting thing I learned - delete returns a tuple.